<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="apple-touch-icon" sizes="76x76" href="./assets/img/apple-icon.png">
    <link rel="icon" type="image/png" href="./assets/img/favicon.png">
    <title>GradeSystem</title>

    <link href="assets/css/css.css" rel="stylesheet">
    <link href="assets/css/nucleo-icons.css" rel="stylesheet">
    <link href="assets/css/nucleo-svg.css" rel="stylesheet">
    <script src="assets/js/349ee9c857.js" crossorigin="anonymous"></script>
    <link href="assets/css/nucleo-svg.css" rel="stylesheet">
    <link id="pagestyle" href="assets/css/corporate-ui-dashboard.css?v=1.0.0" rel="stylesheet">
</head>

<body class="g-sidenav-show  bg-gray-100">

<aside class="sidenav navbar navbar-vertical navbar-expand-xs border-0 bg-slate-900 fixed-start " id="sidenav-main">
    <div class="sidenav-header">
        <i class="fas fa-times p-3 cursor-pointer text-secondary opacity-5 position-absolute end-0 top-0 d-none d-xl-none"
           aria-hidden="true" id="iconSidenav"></i>
        <a class="navbar-brand d-flex align-items-center m-0" href="#">
            <span class="font-weight-bold text-lg">GradeSystem</span>
        </a>
    </div>
    <div class="collapse navbar-collapse px-4  w-auto " id="sidenav-collapse-main">
        <ul class="navbar-nav">
            <li class="nav-item" onclick="menu_click(0)">
                <a class="nav-link " id="menu_0">
                    <div class="icon icon-shape icon-sm px-0 text-center d-flex align-items-center justify-content-center">
                        <svg width="30px" height="30px" viewbox="0 0 48 48" version="1.1"
                             xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                            <title>table</title>
                            <g id="table" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                                <g id="view-grid" transform="translate(12.000000, 12.000000)" fill="#FFFFFF"
                                   fill-rule="nonzero">
                                    <path class="color-foreground"
                                          d="M3.42857143,0 C1.53502286,0 0,1.53502286 0,3.42857143 L0,6.85714286 C0,8.75069143 1.53502286,10.2857143 3.42857143,10.2857143 L6.85714286,10.2857143 C8.75069143,10.2857143 10.2857143,8.75069143 10.2857143,6.85714286 L10.2857143,3.42857143 C10.2857143,1.53502286 8.75069143,0 6.85714286,0 L3.42857143,0 Z"
                                          id="Path"></path>
                                    <path class="color-background"
                                          d="M3.42857143,13.7142857 C1.53502286,13.7142857 0,15.2492571 0,17.1428571 L0,20.5714286 C0,22.4650286 1.53502286,24 3.42857143,24 L6.85714286,24 C8.75069143,24 10.2857143,22.4650286 10.2857143,20.5714286 L10.2857143,17.1428571 C10.2857143,15.2492571 8.75069143,13.7142857 6.85714286,13.7142857 L3.42857143,13.7142857 Z"
                                          id="Path"></path>
                                    <path class="color-background"
                                          d="M13.7142857,3.42857143 C13.7142857,1.53502286 15.2492571,0 17.1428571,0 L20.5714286,0 C22.4650286,0 24,1.53502286 24,3.42857143 L24,6.85714286 C24,8.75069143 22.4650286,10.2857143 20.5714286,10.2857143 L17.1428571,10.2857143 C15.2492571,10.2857143 13.7142857,8.75069143 13.7142857,6.85714286 L13.7142857,3.42857143 Z"
                                          id="Path"></path>
                                    <path class="color-foreground"
                                          d="M13.7142857,17.1428571 C13.7142857,15.2492571 15.2492571,13.7142857 17.1428571,13.7142857 L20.5714286,13.7142857 C22.4650286,13.7142857 24,15.2492571 24,17.1428571 L24,20.5714286 C24,22.4650286 22.4650286,24 20.5714286,24 L17.1428571,24 C15.2492571,24 13.7142857,22.4650286 13.7142857,20.5714286 L13.7142857,17.1428571 Z"
                                          id="Path"></path>
                                </g>
                            </g>
                        </svg>
                    </div>
                    <span class="nav-link-text ms-1">学生</span>
                </a>
            </li>
            <li class="nav-item" onclick="menu_click(1)">
                <a class="nav-link " id="menu_1">
                    <div class="icon icon-shape icon-sm px-0 text-center d-flex align-items-center justify-content-center">
                        <svg width="30px" height="30px" viewbox="0 0 48 48" version="1.1"
                             xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                            <title>table</title>
                            <g id="table" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                                <g id="view-grid" transform="translate(12.000000, 12.000000)" fill="#FFFFFF"
                                   fill-rule="nonzero">
                                    <path class="color-foreground"
                                          d="M3.42857143,0 C1.53502286,0 0,1.53502286 0,3.42857143 L0,6.85714286 C0,8.75069143 1.53502286,10.2857143 3.42857143,10.2857143 L6.85714286,10.2857143 C8.75069143,10.2857143 10.2857143,8.75069143 10.2857143,6.85714286 L10.2857143,3.42857143 C10.2857143,1.53502286 8.75069143,0 6.85714286,0 L3.42857143,0 Z"
                                          id="Path"></path>
                                    <path class="color-background"
                                          d="M3.42857143,13.7142857 C1.53502286,13.7142857 0,15.2492571 0,17.1428571 L0,20.5714286 C0,22.4650286 1.53502286,24 3.42857143,24 L6.85714286,24 C8.75069143,24 10.2857143,22.4650286 10.2857143,20.5714286 L10.2857143,17.1428571 C10.2857143,15.2492571 8.75069143,13.7142857 6.85714286,13.7142857 L3.42857143,13.7142857 Z"
                                          id="Path"></path>
                                    <path class="color-background"
                                          d="M13.7142857,3.42857143 C13.7142857,1.53502286 15.2492571,0 17.1428571,0 L20.5714286,0 C22.4650286,0 24,1.53502286 24,3.42857143 L24,6.85714286 C24,8.75069143 22.4650286,10.2857143 20.5714286,10.2857143 L17.1428571,10.2857143 C15.2492571,10.2857143 13.7142857,8.75069143 13.7142857,6.85714286 L13.7142857,3.42857143 Z"
                                          id="Path"></path>
                                    <path class="color-foreground"
                                          d="M13.7142857,17.1428571 C13.7142857,15.2492571 15.2492571,13.7142857 17.1428571,13.7142857 L20.5714286,13.7142857 C22.4650286,13.7142857 24,15.2492571 24,17.1428571 L24,20.5714286 C24,22.4650286 22.4650286,24 20.5714286,24 L17.1428571,24 C15.2492571,24 13.7142857,22.4650286 13.7142857,20.5714286 L13.7142857,17.1428571 Z"
                                          id="Path"></path>
                                </g>
                            </g>
                        </svg>
                    </div>
                    <span class="nav-link-text ms-1">成绩</span>
                </a>
            </li>
            <li class="nav-item" onclick="menu_click(2)">
                <a class="nav-link " id="menu_2">
                    <div class="icon icon-shape icon-sm px-0 text-center d-flex align-items-center justify-content-center">
                        <svg width="30px" height="30px" viewbox="0 0 48 48" version="1.1"
                             xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
                            <title>table</title>
                            <g id="table" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
                                <g id="view-grid" transform="translate(12.000000, 12.000000)" fill="#FFFFFF"
                                   fill-rule="nonzero">
                                    <path class="color-foreground"
                                          d="M3.42857143,0 C1.53502286,0 0,1.53502286 0,3.42857143 L0,6.85714286 C0,8.75069143 1.53502286,10.2857143 3.42857143,10.2857143 L6.85714286,10.2857143 C8.75069143,10.2857143 10.2857143,8.75069143 10.2857143,6.85714286 L10.2857143,3.42857143 C10.2857143,1.53502286 8.75069143,0 6.85714286,0 L3.42857143,0 Z"
                                          id="Path"></path>
                                    <path class="color-background"
                                          d="M3.42857143,13.7142857 C1.53502286,13.7142857 0,15.2492571 0,17.1428571 L0,20.5714286 C0,22.4650286 1.53502286,24 3.42857143,24 L6.85714286,24 C8.75069143,24 10.2857143,22.4650286 10.2857143,20.5714286 L10.2857143,17.1428571 C10.2857143,15.2492571 8.75069143,13.7142857 6.85714286,13.7142857 L3.42857143,13.7142857 Z"
                                          id="Path"></path>
                                    <path class="color-background"
                                          d="M13.7142857,3.42857143 C13.7142857,1.53502286 15.2492571,0 17.1428571,0 L20.5714286,0 C22.4650286,0 24,1.53502286 24,3.42857143 L24,6.85714286 C24,8.75069143 22.4650286,10.2857143 20.5714286,10.2857143 L17.1428571,10.2857143 C15.2492571,10.2857143 13.7142857,8.75069143 13.7142857,6.85714286 L13.7142857,3.42857143 Z"
                                          id="Path"></path>
                                    <path class="color-foreground"
                                          d="M13.7142857,17.1428571 C13.7142857,15.2492571 15.2492571,13.7142857 17.1428571,13.7142857 L20.5714286,13.7142857 C22.4650286,13.7142857 24,15.2492571 24,17.1428571 L24,20.5714286 C24,22.4650286 22.4650286,24 20.5714286,24 L17.1428571,24 C15.2492571,24 13.7142857,22.4650286 13.7142857,20.5714286 L13.7142857,17.1428571 Z"
                                          id="Path"></path>
                                </g>
                            </g>
                        </svg>
                    </div>
                    <span class="nav-link-text ms-1">用户</span>
                </a>
            </li>
            <li class="nav-item mt-2">
                <div class="d-flex align-items-center nav-link">
                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" class="ms-2" viewbox="0 0 24 24"
                         fill="currentColor">
                        <path fill-rule="evenodd"
                              d="M18.685 19.097A9.723 9.723 0 0021.75 12c0-5.385-4.365-9.75-9.75-9.75S2.25 6.615 2.25 12a9.723 9.723 0 003.065 7.097A9.716 9.716 0 0012 21.75a9.716 9.716 0 006.685-2.653zm-12.54-1.285A7.486 7.486 0 0112 15a7.486 7.486 0 015.855 2.812A8.224 8.224 0 0112 20.25a8.224 8.224 0 01-5.855-2.438zM15.75 9a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z"
                              clip-rule="evenodd"></path>
                    </svg>
                    <span class="font-weight-normal text-md ms-2">我的账户</span>
                </div>
            </li>
            <li class="nav-item border-start my-0 pt-2">
                <a class="nav-link position-relative ms-0 ps-2 py-2 " href="/login">
                    <span class="nav-link-text ms-1">登陆</span>
                </a>
            </li>
            <li class="nav-item border-start my-0 pt-2">
                <a class="nav-link position-relative ms-0 ps-2 py-2 " href="/register">
                    <span class="nav-link-text ms-1">注册</span>
                </a>
            </li>
        </ul>
    </div>
</aside>
<main class="main-content position-relative max-height-vh-100 h-100 border-radius-lg ">

    <nav class="navbar navbar-main navbar-expand-lg mx-5 px-0 shadow-none rounded" id="navbarBlur" navbar-scroll="true">
        <div class="container-fluid py-1 px-2">
            <nav aria-label="breadcrumb">
                <ol class="breadcrumb bg-transparent mb-1 pb-0 pt-1 px-0 me-sm-6 me-5">
                    <li class="breadcrumb-item text-sm"><a class="opacity-5 text-dark" href="javascript:;">系统</a>
                    </li>
                    <li class="breadcrumb-item text-sm text-dark active" aria-current="page">数据</li>
                </ol>
                <h6 class="font-weight-bold mb-0">表格</h6>
            </nav>
            <div class="collapse navbar-collapse mt-sm-0 mt-2 me-md-0 me-sm-4" id="navbar">
                <div class="ms-md-auto pe-md-3 d-flex align-items-center">
                    <ul class="navbar-nav  justify-content-end">
                        <li class="nav-item px-3 d-flex align-items-center">
                            <a href="javascript:;" class="nav-link text-body p-0">
                                <svg width="16" height="16" xmlns="http://www.w3.org/2000/svg"
                                     class="fixed-plugin-button-nav cursor-pointer" viewbox="0 0 24 24"
                                     fill="currentColor">
                                    <path fill-rule="evenodd"
                                          d="M11.078 2.25c-.917 0-1.699.663-1.85 1.567L9.05 4.889c-.02.12-.115.26-.297.348a7.493 7.493 0 00-.986.57c-.166.115-.334.126-.45.083L6.3 5.508a1.875 1.875 0 00-2.282.819l-.922 1.597a1.875 1.875 0 00.432 2.385l.84.692c.095.078.17.229.154.43a7.598 7.598 0 000 1.139c.015.2-.059.352-.153.43l-.841.692a1.875 1.875 0 00-.432 2.385l.922 1.597a1.875 1.875 0 002.282.818l1.019-.382c.115-.043.283-.031.45.082.312.214.641.405.985.57.182.088.277.228.297.35l.178 1.071c.151.904.933 1.567 1.85 1.567h1.844c.916 0 1.699-.663 1.85-1.567l.178-1.072c.02-.12.114-.26.297-.349.344-.165.673-.356.985-.57.167-.114.335-.125.45-.082l1.02.382a1.875 1.875 0 002.28-.819l.923-1.597a1.875 1.875 0 00-.432-2.385l-.84-.692c-.095-.078-.17-.229-.154-.43a7.614 7.614 0 000-1.139c-.016-.2.059-.352.153-.43l.84-.692c.708-.582.891-1.59.433-2.385l-.922-1.597a1.875 1.875 0 00-2.282-.818l-1.02.382c-.114.043-.282.031-.449-.083a7.49 7.49 0 00-.985-.57c-.183-.087-.277-.227-.297-.348l-.179-1.072a1.875 1.875 0 00-1.85-1.567h-1.843zM12 15.75a3.75 3.75 0 100-7.5 3.75 3.75 0 000 7.5z"
                                          clip-rule="evenodd"></path>
                                </svg>
                            </a>
                        </li>
                        <li class="nav-item ps-2 d-flex align-items-center">
                            <a href="javascript:;" class="nav-link text-body p-0">
                                <img src="./assets/img/team-2.jpg" class="avatar avatar-sm" alt="avatar">
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>

    <div class="container-fluid py-4 px-5">
        <div class="row">
            <div class="col-12">
                <div class="card card-background card-background-after-none align-items-start mt-4 mb-5">
                    <div class="full-background"
                         style="background-image: url('./assets/img/header-blue-purple.jpg')"></div>
                    <div class="card-body text-start p-4 w-100">
                        <h3 class="text-white mb-2">GradeSystem</h3>
                        <p class="mb-4 font-weight-semibold">
                            开始管理你的数据吧~
                        </p>
                        <img src="./assets/img/3d-cube.png" alt="3d-cube"
                             class="position-absolute top-0 end-1 w-25 max-width-200 mt-n6 d-sm-block d-none">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-12">
                <div class="card border shadow-xs mb-4">
                    <div class="card-header border-bottom pb-0">
                        <div class="d-sm-flex align-items-center mb-3">
                            <div class="ms-auto d-flex">
                                <div class="input-group input-group-sm ms-auto me-2">
                    <span class="input-group-text text-body">
                      <svg xmlns="http://www.w3.org/2000/svg" width="16px" height="16px" fill="none" viewbox="0 0 24 24"
                           stroke-width="1.5" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round"
                              d="M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"></path>
                      </svg>
                    </span>
                                    <input id="search_inp" type="text" class="form-control form-control-sm"
                                           placeholder="搜索">
                                </div>
                                <button type="button" onclick="search_click()"
                                        class="btn btn-sm btn-dark btn-icon d-flex align-items-center mb-0 me-2">
                                    <span class="btn-inner--text">Search</span>
                                </button>
                                <button type="button" onclick="add_click()"
                                        class="btn btn-sm btn-dark btn-icon d-flex align-items-center mb-0 me-2">
                                    <span class="btn-inner--text">Add</span>
                                </button>
                            </div>
                        </div>
                    </div>
                    <div class="card-body px-0 py-0">
                        <div class="table-responsive p-0">
                            <table class="table align-items-center justify-content-center mb-0">
                                <thead class="bg-gray-100">
                                <tr id="table_name_tr">
               
                                </tr>
                                </thead>
                                <tbody id="table_data_tr">
                          
                                </tbody>
                            </table>
                        </div>
                        <div class="border-top py-3 px-3 d-flex align-items-center">

                            <nav aria-label="..." class="ms-auto">
                                <ul class="pagination pagination-light mb-0" id="page_ul">
                            
                                </ul>
                            </nav>
            
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<div class="fixed-plugin">
    <a class="fixed-plugin-button text-dark position-fixed px-3 py-2">
        <i class="fa fa-cog py-2"></i>
    </a>
    <div class="card shadow-lg ">
        <div class="card-header pb-0 pt-3 ">
            <div class="float-start">
                <h5 class="mt-3 mb-0">GradeSystem Configurator</h5>
                <p>管理系统设置</p>
            </div>
            <div class="float-end mt-4">
                <button class="btn btn-link text-dark p-0 fixed-plugin-close-button">
                    <i class="fa fa-close"></i>
                </button>
            </div>

        </div>
        <hr class="horizontal dark my-1">
        <div class="card-body pt-sm-3 pt-0">
            <div>
                <h6 class="mb-0">图标颜色</h6>
            </div>
            <a href="javascript:void(0)" class="switch-trigger background-color">
                <div class="badge-colors my-2 text-start">
                    <span class="badge filter bg-gradient-primary active" data-color="primary"
                          onclick="sidebarColor(this)"></span>
                    <span class="badge filter bg-gradient-info" data-color="info" onclick="sidebarColor(this)"></span>
                    <span class="badge filter bg-gradient-success" data-color="success"
                          onclick="sidebarColor(this)"></span>
                    <span class="badge filter bg-gradient-warning" data-color="warning"
                          onclick="sidebarColor(this)"></span>
                    <span class="badge filter bg-gradient-danger" data-color="danger"
                          onclick="sidebarColor(this)"></span>
                </div>
            </a>

            <div class="mt-3">
                <h6 class="mb-0">模式切换</h6>
                <p class="text-sm">白天/黑夜</p>
            </div>
            <div class="d-flex">
                <button class="btn bg-gradient-primary w-100 px-3 mb-2 active" data-class="bg-slate-900"
                        onclick="sidebarType(this)">暗
                </button>
                <button class="btn bg-gradient-primary w-100 px-3 mb-2 ms-2" data-class="bg-white"
                        onclick="sidebarType(this)">亮
                </button>
            </div>

            <div class="mt-3">
                <h6 class="mb-0">块状导航</h6>
            </div>
            <div class="form-check form-switch ps-0">
                <input class="form-check-input mt-1 ms-auto" type="checkbox" id="navbarFixed"
                       onclick="navbarFixed(this)">
            </div>
            <hr class="horizontal dark my-sm-4">
        </div>
    </div>
</div>

<script src="./assets/js/core/popper.min.js"></script>
<script src="./assets/js/core/bootstrap.min.js"></script>
<script src="./assets/js/plugins/perfect-scrollbar.min.js"></script>
<script src="./assets/js/plugins/smooth-scrollbar.min.js"></script>
<script>
    var win = navigator.platform.indexOf('Win') > -1;
    if (win && document.querySelector('#sidenav-scrollbar')) {
        var options = {
            damping: '0.5'
        }
        Scrollbar.init(document.querySelector('#sidenav-scrollbar'), options);
    }
</script>

<script async defer src="assets/js/buttons.js"></script>

<script src="./assets/js/corporate-ui-dashboard.min.js?v=1.0.0"></script>
</body>

<script src="assets/js/jquery-3.6.0.min.js"></script>
<script src="assets/js/jqPaginator.js"></script>
<script src="assets/js/my_tool.js"></script>

<script type="text/javascript">


    isLogin()

    let menu_name = window.localStorage.getItem("menu_name")
    if (menu_name === null) {
        menu_name = "menu_student"
        window.localStorage.setItem("menu_name", menu_name)
    }

    let data_lst = []
    let search_data_lst = []
    let show_data_lst = []

    let menu_name_lst = ["menu_student", "menu_grade", "menu_user"]

    let table_name_dict = {
        "menu_student": ["编号", "姓名", "性别", "年龄", "电话", "籍贯"],
        "menu_grade": ["编号", "学生", "科目", "成绩", "记录日期"],
        "menu_user": ["编号", "用户名", "密码", "身份"]
    }

    let aj_req_dict = {
        "menu_student": "/aj_sel_student_by_all",
        "menu_grade": "/aj_sel_grade_by_all",
        "menu_user": "/aj_sel_user_by_all",
    }

    let aj_del_dict = {
        "menu_student": "/aj_del_student_by_id",
        "menu_grade": "/aj_del_grade_by_id",
        "menu_user": "/aj_del_user_by_id",
    }

    let aj_info_dict = {
        "menu_student": studentInfoPage,
        "menu_grade": gradeInfoPage,
        "menu_user": registerPage
    }

    let page_item_num = 10

    function rep_item_data(key, value, index) {
        if (key === "id") {
            value = (index + 1)
        } else if (key === "sex") {
            value = (value === 0 ? "男" : "女")
        } else if (key === "pwd") {
            value = "***"
        } else if (key === "status") {
            value = "管理员"
        } else if (key === "student_id") {
            value = find_id_to_student(value)
        }
        return value
    }

    function find_id_to_student(value) {
        let result = value
        $.ajax({
            url: "/aj_sel_student_by_id",
            type: 'POST',
            data: {"id": value},
            async: false,
            dataType: 'text',
            success: function (data) {
                result = JSON.parse(data)
            },
            error: function () {
                window.alert("请求错误!")
            }
        });
        return result.name + "(" + result.id + ")"
    }


    function rfTableHead() {
        let table_name_lst = table_name_dict[menu_name]
        let table_name_tr = ""
        for (let i = 0; i < table_name_lst.length; i++) {
            table_name_tr += "<th class='text-secondary text-xs font-weight-semibold opacity-7 '>" + table_name_lst[i] + "</th>"
        }
        table_name_tr += "<th class='text-secondary text-xs font-weight-semibold opacity-7 '>" + "操作" + "</th>"
        $("#table_name_tr").html(table_name_tr)
    }

    function rfTable(page_num, data_table_lst) {
        if (page_num === 1) {
            show_data_lst = data_table_lst.slice(0, page_item_num)
        } else {
            show_data_lst = data_table_lst.slice((page_num - 1) * page_item_num, page_num * page_item_num)
        }

        let table_data_tr = ""
        for (let i = 0; i < show_data_lst.length; i++) {
            let item_dict = show_data_lst[i]
            table_data_tr += "<tr>"
            for (const [key, value] of Object.entries(item_dict)) {
                table_data_tr += "<td >"
                table_data_tr += "<p class='text-secondary text-xs font-weight-semibold'>"
                table_data_tr += rep_item_data(key, value, i)
                table_data_tr += "</p>"
                table_data_tr += "</td>"
            }

            table_data_tr += "<td>"
            if (menu_name !== "menu_user") {
                table_data_tr += "<button class='text-xs font-weight-semibold  btn btn-info btn-sm' " + "onclick='upd_click(" + item_dict.id + ")'" + ">" + "修改" + "</button>"
            }
            table_data_tr += "<button class='text-xs font-weight-semibold  btn btn-danger btn-sm' " + "onclick='del_click(" + item_dict.id + ")'" + ">" + "删除" + "</button>"
            table_data_tr += "</td>"

            table_data_tr += "</tr>"
        }
        $("#table_data_tr").html(table_data_tr)
    }

    function rfMenu() {
        for (let i = 0; i < menu_name_lst.length; i++) {
            $("#menu_" + i).removeClass("active")
        }
        let menu_index = menu_name_lst.indexOf(menu_name);
        $("#menu_" + menu_index).addClass("active")
    }

    function rfPageNav(data_table_lst) {
        let total_pages = Math.ceil(data_table_lst.length / page_item_num);
        $("#page_ul").jqPaginator({
            totalPages: total_pages,
            visiblePages: 3,
            currentPage: 1,
            first: '<li class="btn btn-sm btn-white d-sm-block d-none mb-0 ms-auto"><a href="javascript:void(0);">First</a></li>',
            prev: '<li class="btn btn-sm btn-white d-sm-block d-none mb-0 ms-auto"><a href="javascript:void(0);">Previous</a></li>',
            next: '<li class="btn btn-sm btn-white d-sm-block d-none mb-0 ms-auto"><a href="javascript:void(0);">Next</a></li>',
            last: '<li class="btn btn-sm btn-white d-sm-block d-none mb-0 ms-auto"><a href="javascript:void(0);">Last</a></li>',
            page: '<li class="btn btn-sm btn-white d-sm-block d-none mb-0 ms-auto"><a href="javascript:void(0);">{{page}}</a></li>',
            onPageChange: function (page_num) {
                rfTable(page_num, data_table_lst)
            }
        })
    }

    function rfData() {
        let url = aj_req_dict[menu_name]
        $.ajax({
            url: url,
            type: 'POST',
            data: {},
            dataType: 'text',
            success: function (data) {
                data_lst = JSON.parse(data)
                rfTableHead()
                rfMenu()
                rfPageNav(data_lst)
            },
            error: function () {
                window.alert("请求错误!")
            }
        });
    }

    function search_click() {
        let search_content = $("#search_inp").val()
        search_content = $.trim(search_content)
        search_data_lst = []
        if (search_content === "") {
            rfPageNav(data_lst)
            return
        }
        for (let i = 0; i < data_lst.length; i++) {
            let item_dict = data_lst[i]
            for (const [key, value] of Object.entries(item_dict)) {
                if ((value + "").indexOf(search_content) !== -1) {
                    search_data_lst.push(item_dict)
                    break
                }
            }
        }
        rfPageNav(search_data_lst)
    }

    function menu_click(index) {
        let menu_name = menu_name_lst[index]
        window.localStorage.setItem("menu_name", menu_name)
        window.location = homePage
    }

    function add_click() {
        window.localStorage.setItem("cur_item_id", "")
        window.location = aj_info_dict[menu_name]
    }

    function upd_click(ids) {
        window.localStorage.setItem("cur_item_id", ids + "")
        window.location = aj_info_dict[menu_name]
    }

    function del_click(ids) {
        let url = aj_del_dict[menu_name]
        $.ajax({
            url: url,
            type: 'POST',
            data: {"id": ids},
            dataType: 'text',
            success: function (data) {
                data = parseInt(data)
                if (data === -1) {
                    window.alert("删除错误！")
                } else {
                    window.alert("删除成功！")
                }
                window.location = homePage
            },
            error: function () {
                window.alert("请求错误!")
            }
        });
    }

    rfData()


</script>

</html>